package entity;

import java.io.Serializable;
import java.util.List;

/**
 * @version 1.0
 * @Author: xxf
 * @CreateDate: 2020/10/5 14:30
 */
public class PageBean<T> {


    private List<T> list;
    private int currentPage;//当前页数
    private int pageSize;//一页展示信息的条数
    private long totalCount;//总条数
    private int totalPage;//总页数
    private String url;//请求的url地址

    @Override
    public String toString() {
        return "PageBean{" +
                "list=" + list +
                ", currentPage=" + currentPage +
                ", pageSize=" + pageSize +
                ", totalCount=" + totalCount +
                ", totalPage=" + totalPage +
                ", url='" + url + '\'' +
                '}';
    }

    public PageBean() {
    }

    public PageBean(List<T> list, int currentPage, int pageSize, long totalCount, String url) {
        this.list = list;
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
        this.url = url;
        this.totalPage = (int) (totalCount % pageSize == 0 ? totalCount / pageSize : totalCount / pageSize + 1);

    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
        //设置总页数
        if (pageSize > 0 && totalCount > 0) {
            this.totalPage = (int) (totalCount % pageSize == 0 ? totalCount / pageSize : totalCount / pageSize + 1);
        }
    }

    public long getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(long totalCount) {
        this.totalCount = totalCount;
        //设置总页数
        if (pageSize > 0 && totalCount > 0) {
            this.totalPage = (int) (totalCount % pageSize == 0 ? totalCount / pageSize : totalCount / pageSize + 1);
        }

    }

    public int getTotalPage() {
        return totalPage;
    }

    /*public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }*/

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }
}
